<?php

/**
 * Created by PhpStorm.
 * User: linux
 * Date: 12/01/2018
 * Time: 2:22 PM
 */
namespace Criteria;

use Criteria\Criteria\AndCriteria;
use Criteria\Criteria\CriteriaFemal;
use Criteria\Criteria\CriteriaMale;
use Criteria\Criteria\CriteriaSingle;
use Criteria\Criteria\OrCriteria;

function test()
{
    $lists = [];
    $lists[] = new Person\Person('nameA', 'MALE', 'SINGLE');
    $lists[] = new Person\Person('nameB', 'MALE', 'MARRIED');
    $lists[] = new Person\Person('nameC', 'FEMALE', 'MARRIED');
    $lists[] = new Person\Person('nameD', 'FEMALE', 'SINGLE');
    $lists[] = new Person\Person('nameE', 'MALE', 'SINGLE');
    $lists[] = new Person\Person('nameF', 'MALE', 'SINGLE');

    $maleCriteria = new CriteriaMale();
    $femaleCriteria = new CriteriaFemal();
    $singleCriteria = new CriteriaSingle();
    $maleSingleCriteria = new AndCriteria($maleCriteria, $singleCriteria);
    $femaleOrSingleCriteria = new OrCriteria($femaleCriteria, $singleCriteria);

    echo 'MALE:' . "\r\n";
    print_r($maleCriteria->meetCriteria($lists));

    echo 'FEMALE:' . "\r\n";
    print_r($femaleCriteria->meetCriteria($lists));

    echo 'SINGLE' . "\r\n";
    print_r($singleCriteria->meetCriteria($lists));

    echo 'MALE AND SINGLE' . "\r\n";
    print_r($maleSingleCriteria->meetCriteria($lists));

    echo 'FEMALE OR SINGLE' . "\r\n";
    print_r($femaleOrSingleCriteria->meetCriteria($lists));

}
